package com.project.yunshitong;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;

import com.project.yunshitong.bean.GoodsInfo;

import java.util.ArrayList;
import java.util.List;

public class Utils {
    public static String getAppVersionName(Context context) {
        String versionName = "";
        try {
            PackageManager pm = context.getPackageManager();
            PackageInfo pi = pm.getPackageInfo(context.getPackageName(),0);
            versionName = pi.versionName;
            if (versionName == null || versionName.length() <= 0) {
                return "";
            }
        } catch (Exception e) {
            Log.e("VersionInfo", "Exception", e);
        }
        return versionName;

    }

    private static Toast mToast = null;
    public  static void getToast(Context context, String resId) {
        if (null == mToast) {
            mToast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
        }
        mToast.setGravity(Gravity.CENTER,0,0);
        mToast.setText(resId);
        mToast.show();
    }
//    private static List<GoodsInfo> list = new ArrayList<>();
//    public static List<GoodsInfo> getList(){
//        return list;
//    }
//    public static void setList(List<GoodsInfo> list1){
//        list = list1;
//    }
}
